//
//  TSCardEmptyView.swift
//  TSProfitProject
//
//  Created by TMS on 2019/11/8.
//  Copyright © 2019 TMS. All rights reserved.
//

import UIKit

protocol TSCardEmptyViewDelegate : NSObjectProtocol {
    func didClickBind()
}

class TSCardEmptyView: UIView {

    weak var delegate : TSCardEmptyViewDelegate? = nil
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = WHITE_COLOR
        configViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func bindAction() {
        if self.delegate != nil {
            self.delegate?.didClickBind()
        }
    }
    
    func configViews() {
        
        let emptyImg = UIImageView.init(image: UIImage(named: "general_card_empty"))
        self.addSubview(emptyImg)
        emptyImg.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(50)
            make.size.equalTo(CGSize(width: 103, height: 137))
        }

        let bindBtn = UIButton.init(type: .system)
        bindBtn.setTitle("立即绑卡", for: .normal)
        bindBtn.setTitleColor(WHITE_COLOR, for: .normal)
        bindBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .medium)
        bindBtn.backgroundColor = BASE_PURPLE_COLOR
        bindBtn.layer.cornerRadius = 24
        bindBtn.layer.masksToBounds = true
        bindBtn.addTarget(self, action: #selector(bindAction), for: .touchUpInside)
        self.addSubview(bindBtn)
        bindBtn.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(emptyImg.snp_bottom).offset(36)
            make.size.equalTo(CGSize(width: SCREEN_WIDTH*0.682, height: 48))
        }
    }

}
